<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>AdWords::AdWordsCredentials</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
    <script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>     
    <div class="banner">
        <h1>
            <span class="type">Class</span> 
            AdWords::AdWordsCredentials 
            
                <span class="parent">&lt; 
                    
                    Object
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/lib/adwords4r/credentials_rb.html">lib/adwords4r/credentials.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
    
    <div class="description">
        <p>
Generic credentials class, used for any <a href="API.html">API</a> version.
</p>

    </div>
    

    

    
    

    
    
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
    
        <dt>A</dt>
        <dd>
            <ul>
                
                <li><a href="#method-i-auth_token">auth_token</a></li>
                
            </ul>
        </dd>
    
        <dt>C</dt>
        <dd>
            <ul>
                
                <li><a href="#method-i-client_customer_id">client_customer_id</a>,</li>
                
                <li><a href="#method-i-client_email">client_email</a></li>
                
            </ul>
        </dd>
    
        <dt>D</dt>
        <dd>
            <ul>
                
                <li><a href="#method-i-dup">dup</a></li>
                
            </ul>
        </dd>
    
        <dt>G</dt>
        <dd>
            <ul>
                
                <li><a href="#method-i-generate_auth_token">generate_auth_token</a>,</li>
                
                <li><a href="#method-i-get_handlers">get_handlers</a></li>
                
            </ul>
        </dd>
    
        <dt>N</dt>
        <dd>
            <ul>
                
                <li><a href="#method-c-new">new</a></li>
                
            </ul>
        </dd>
    
        <dt>S</dt>
        <dd>
            <ul>
                
                <li><a href="#method-i-set_header">set_header</a></li>
                
            </ul>
        </dd>
    
    </dl>
    

    

    

    

    

    
    <div class="sectiontitle">Attributes</div>
    <table border='0' cellpadding='5'>
        
        <tr valign='top'>
            <td class='attr-rw'>
                [R]
            </td>
            <td class='attr-name'>credentials</td>
            <td class='attr-desc'><p>
Hash of credentials (credential key to value)
</p></td>
        </tr>
        
        <tr valign='top'>
            <td class='attr-rw'>
                [R]
            </td>
            <td class='attr-name'>environment</td>
            <td class='attr-desc'><p>
The environment being used (production, sandbox)
</p></td>
        </tr>
        
        <tr valign='top'>
            <td class='attr-rw'>
                [RW]
            </td>
            <td class='attr-name'>use_mcc</td>
            <td class='attr-desc'><p>
Whether we&#8217;re making MCC-level requests
</p></td>
        </tr>
        
        <tr valign='top'>
            <td class='attr-rw'>
                [RW]
            </td>
            <td class='attr-name'>validate_only</td>
            <td class='attr-desc'><p>
Whether we&#8217;re making validate-only requests
</p></td>
        </tr>
        
    </table>
    

    
            <div class="sectiontitle">Class Public methods</div>
            
            <div class="method">
                <div class="title" id="method-c-new">
                    
                    <a name="method-c-new"></a><b>new</b>(credentials=nil)
                    
                </div>
                
                <div class="description">
                  <p>
Constructor for <a href="AdWordsCredentials.html">AdWordsCredentials</a>.
</p>
<p>
Args:
</p>
<ul>
<li><p>
credentials: Hash of credentials (credential key to value). E.g.:
</p>
<pre>
 {
  'developerToken' =&gt; 'user@domain.com++USD',
  'useragent' =&gt; 'Sample User Agent',
  'password' =&gt; 'password',
  'email' =&gt; 'user@domain.com',
  'clientEmail' =&gt; 'client_1+user@domain.com',
  'applicationToken' =&gt; 'IGNORED',
  'environment' =&gt; 'SANDBOX'
 }</pre>
</li>
</ul>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                        
                    </p>
                    <div id="method-c-new_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 147</span>
147:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">credentials</span>=<span class="ruby-keyword kw">nil</span>)
148:       <span class="ruby-ivar">@credentials</span> = {}
149:       <span class="ruby-ivar">@environment</span> = <span class="ruby-keyword kw">nil</span>
150:       <span class="ruby-ivar">@auth_token</span> = <span class="ruby-keyword kw">nil</span>
151:       <span class="ruby-ivar">@handlers</span> = []
152:       <span class="ruby-ivar">@use_mcc</span> = <span class="ruby-keyword kw">false</span>
153:       <span class="ruby-ivar">@validate_only</span> = <span class="ruby-keyword kw">false</span>
154:       <span class="ruby-identifier">credentials</span> = <span class="ruby-identifier">get_defaults</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">credentials</span>.<span class="ruby-identifier">nil?</span>
155:       <span class="ruby-identifier">credentials</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
156:         <span class="ruby-comment cmt"># 'environment' shouldn't go in the credentials array, and we'll ignore</span>
157:         <span class="ruby-comment cmt"># 'alternateUrl' to avoid errors on upgraders' apps.</span>
158:         <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^alternateUrl/</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">credentials</span>[<span class="ruby-value str">&quot;environment&quot;</span>].<span class="ruby-identifier">nil?</span>)
159:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>,
160:               <span class="ruby-value str">&quot;'alternateUrl' is no longer supported. Please consult the &quot;</span> <span class="ruby-operator">+</span>
161:               <span class="ruby-value str">&quot;Readme on how to use 'environment' instead.&quot;</span>
162:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^environment/</span>)
163:           <span class="ruby-ivar">@credentials</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
164:         <span class="ruby-keyword kw">end</span>
165:       <span class="ruby-keyword kw">end</span>
166: 
167:       <span class="ruby-comment cmt"># The user agent header differs in v13 (useragent) and v2009 (userAgent).</span>
168:       <span class="ruby-comment cmt"># Properly populate both values, and use the name of the program ($0) if</span>
169:       <span class="ruby-comment cmt"># nothing is given.</span>
170:       <span class="ruby-identifier">user_agent</span> = <span class="ruby-value str">'adwords4r: %s'</span> <span class="ruby-operator">%</span> (<span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'useragent'</span>] <span class="ruby-operator">||</span>
171:         <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'userAgent'</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">$0</span>)
172:       <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'useragent'</span>] = <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'userAgent'</span>] = <span class="ruby-identifier">user_agent</span>
173: 
174:       <span class="ruby-comment cmt"># The properties file may include the clientEmail in a clientId property.</span>
175:       <span class="ruby-comment cmt"># clientId might be a clientCustomerId, though, so check to make sure it</span>
176:       <span class="ruby-comment cmt"># is an email address before assigning it to clientEmail.</span>
177:       <span class="ruby-comment cmt"># clientCustomerIds don't seem to be supported elsewhere in this client</span>
178:       <span class="ruby-comment cmt"># library, so ignore them.</span>
179:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientEmail'</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientId'</span>] <span class="ruby-keyword kw">and</span>
180:           <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientId'</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'@'</span>)
181:         <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientEmail'</span>] = <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientId'</span>]
182:       <span class="ruby-keyword kw">end</span>
183: 
184:       <span class="ruby-comment cmt"># Normalize 'token' to 'developerToken'</span>
185:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'developerToken'</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'token'</span>]
186:         <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'developerToken'</span>] = <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'token'</span>]
187:         <span class="ruby-ivar">@credentials</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">'token'</span>)
188:       <span class="ruby-keyword kw">end</span>
189: 
190:       <span class="ruby-comment cmt"># Set environment</span>
191:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'environment'</span>].<span class="ruby-identifier">nil?</span>
192:         <span class="ruby-comment cmt"># Get default environment</span>
193:         <span class="ruby-ivar">@environment</span> = <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Service</span>.<span class="ruby-identifier">get_default_environment</span>
194:       <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span>(<span class="ruby-constant">Service</span>.<span class="ruby-identifier">get_environments</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'environment'</span>]))
195:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>,
196:             <span class="ruby-node">&quot;Unknown environment: #{credentials['environment']}&quot;</span>
197:       <span class="ruby-keyword kw">else</span>
198:         <span class="ruby-ivar">@environment</span> = <span class="ruby-identifier">credentials</span>[<span class="ruby-value str">'environment'</span>]
199:       <span class="ruby-keyword kw">end</span>
200: 
201:       <span class="ruby-comment cmt"># Fix potential problems with changing clientEmail, by forcing it to be</span>
202:       <span class="ruby-comment cmt"># created</span>
203:       <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientEmail'</span>] = <span class="ruby-value str">''</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientEmail'</span>].<span class="ruby-identifier">nil?</span>
204: 
205:       <span class="ruby-comment cmt"># Check for environment mismatches.</span>
206:       <span class="ruby-identifier">validate_headers_for_server</span>
207: 
208:       <span class="ruby-ivar">@credentials</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
209:         <span class="ruby-ivar">@handlers</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Pre2009HeaderHandler</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>, <span class="ruby-keyword kw">self</span>)
210:       <span class="ruby-keyword kw">end</span>
211:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="sectiontitle">Instance Public methods</div>
            
            <div class="method">
                <div class="title" id="method-i-auth_token">
                    
                    <a name="method-i-auth_token"></a><b>auth_token</b>()
                    
                </div>
                
                <div class="description">
                  <p>
Returns the authentication token used with >= v2009 requests. Generates it
if there&#8217;s no valid token already generated.
</p>
<p>
Returns: The auth token (as a string).
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-auth_token_source')" id="l_method-i-auth_token_source">show</a>
                        
                    </p>
                    <div id="method-i-auth_token_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 265</span>
265:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">auth_token</span>
266:       <span class="ruby-identifier">generate_auth_token</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@auth_token</span>.<span class="ruby-identifier">nil?</span>
267:       <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@auth_token</span>
268:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="method-i-client_customer_id">
                    
                    <a name="method-i-client_customer_id"></a><b>client_customer_id</b>()
                    
                </div>
                
                <div class="description">
                  <p>
Returns the client customer ID currently being used (dependent on whether
MCC-level requests are enabled or disabled)
</p>
<p>
Returns: Client customer ID if <a
href="AdWordsCredentials.html#use_mcc">use_mcc</a> is false, empty string
otherwise
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-client_customer_id_source')" id="l_method-i-client_customer_id_source">show</a>
                        
                    </p>
                    <div id="method-i-client_customer_id_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 233</span>
233:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">client_customer_id</span>
234:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@use_mcc</span>
235:         <span class="ruby-keyword kw">return</span> <span class="ruby-value str">''</span>
236:       <span class="ruby-keyword kw">else</span>
237:         <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientCustomerId'</span>]
238:       <span class="ruby-keyword kw">end</span>
239:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="method-i-client_email">
                    
                    <a name="method-i-client_email"></a><b>client_email</b>()
                    
                </div>
                
                <div class="description">
                  <p>
Returns the client email currently being used (dependent on whether
MCC-level requests are enabled or disabled)
</p>
<p>
Returns: Client email if <a
href="AdWordsCredentials.html#use_mcc">use_mcc</a> is false, empty string
otherwise
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-client_email_source')" id="l_method-i-client_email_source">show</a>
                        
                    </p>
                    <div id="method-i-client_email_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 219</span>
219:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">client_email</span>
220:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@use_mcc</span>
221:         <span class="ruby-keyword kw">return</span> <span class="ruby-value str">''</span>
222:       <span class="ruby-keyword kw">else</span>
223:         <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'clientEmail'</span>]
224:       <span class="ruby-keyword kw">end</span>
225:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="method-i-dup">
                    
                    <a name="method-i-dup"></a><b>dup</b>()
                    
                </div>
                
                <div class="description">
                  <p>
Overloads the &#8216;dup&#8217; method for <a
href="AdWordsCredentials.html">AdWordsCredentials</a> to correctly
duplicate objects of this class.
</p>
<p>
Returns: Duplicated <a
href="AdWordsCredentials.html">AdWordsCredentials</a> object
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-dup_source')" id="l_method-i-dup_source">show</a>
                        
                    </p>
                    <div id="method-i-dup_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 320</span>
320:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dup</span>
321:       <span class="ruby-identifier">creds</span> = <span class="ruby-ivar">@credentials</span>.<span class="ruby-identifier">dup</span>
322:       <span class="ruby-comment cmt"># Remove the prepended 'adwords4r: ' string before creating the duplicate</span>
323:       <span class="ruby-identifier">creds</span>[<span class="ruby-value str">'userAgent'</span>][<span class="ruby-value str">'adwords4r: '</span>] = <span class="ruby-value str">''</span>
324:       <span class="ruby-identifier">creds</span>[<span class="ruby-value str">'environment'</span>] = <span class="ruby-ivar">@environment</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@environment</span>.<span class="ruby-identifier">nil?</span>
325:       <span class="ruby-keyword kw">return</span> <span class="ruby-constant">AdWordsCredentials</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">creds</span>)
326:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="method-i-generate_auth_token">
                    
                    <a name="method-i-generate_auth_token"></a><b>generate_auth_token</b>()
                    
                </div>
                
                <div class="description">
                  <p>
Generates a new authentication token used with >= v2009 requests. The
generated token is stored and can later be accessed with auth_token. It
should only be necessary for user code to invoke this if the first token
expires.
</p>
<p>
Returns: The auth token (as a string).
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-generate_auth_token_source')" id="l_method-i-generate_auth_token_source">show</a>
                        
                    </p>
                    <div id="method-i-generate_auth_token_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 278</span>
278:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate_auth_token</span>
279:       <span class="ruby-identifier">email</span> = <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'email'</span>]
280:       <span class="ruby-identifier">password</span> = <span class="ruby-ivar">@credentials</span>[<span class="ruby-value str">'password'</span>]
281: 
282:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">email</span>.<span class="ruby-identifier">nil?</span>
283:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">AuthError</span>,
284:             <span class="ruby-value str">'Email address not included in credentials.'</span>
285:       <span class="ruby-keyword kw">end</span>
286: 
287:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">password</span>.<span class="ruby-identifier">nil?</span>
288:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">AuthError</span>, <span class="ruby-value str">'Password not included in credentials.'</span>
289:       <span class="ruby-keyword kw">end</span>
290: 
291:       <span class="ruby-identifier">hostname</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">use_ssl</span> = <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Service</span>.<span class="ruby-identifier">get_auth_server</span>(<span class="ruby-ivar">@environment</span>)
292:       <span class="ruby-ivar">@auth_token</span> = <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">AuthToken</span><span class="ruby-operator">::</span><span class="ruby-identifier">get_token</span>(<span class="ruby-identifier">email</span>, <span class="ruby-identifier">password</span>, <span class="ruby-identifier">hostname</span>,
293:           <span class="ruby-identifier">port</span>, <span class="ruby-identifier">use_ssl</span>)
294:       <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@auth_token</span>
295:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="method-i-get_handlers">
                    
                    <a name="method-i-get_handlers"></a><b>get_handlers</b>(version, driver)
                    
                </div>
                
                <div class="description">
                  <p>
Return a list of handlers to be inserted into the driver&#8217;s handler
list.
</p>
<p>
Args:
</p>
<ul>
<li><p>
version: <a href="API.html">API</a> version being used. Must be an integer.
</p>
</li>
<li><p>
driver: the driver for the service being handled
</p>
</li>
</ul>
<p>
Returns: The list of handlers (subclasses of SOAP::Header::SimpleHandler)
</p>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-get_handlers_source')" id="l_method-i-get_handlers_source">show</a>
                        
                    </p>
                    <div id="method-i-get_handlers_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 250</span>
250:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_handlers</span>(<span class="ruby-identifier">version</span>, <span class="ruby-identifier">driver</span>)
251:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">version</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Integer</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">version</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">13</span> <span class="ruby-keyword kw">then</span>
252:         <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@handlers</span>
253:       <span class="ruby-keyword kw">else</span>
254:         <span class="ruby-identifier">namespace</span> = <span class="ruby-constant">AdWords</span><span class="ruby-operator">::</span><span class="ruby-constant">Service</span>.<span class="ruby-identifier">get_namespace_v2009</span>(<span class="ruby-identifier">driver</span>)
255:         <span class="ruby-keyword kw">return</span> [<span class="ruby-constant">V2009HeaderHandler</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">namespace</span>, <span class="ruby-identifier">version</span>)]
256:       <span class="ruby-keyword kw">end</span>
257:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
            <div class="method">
                <div class="title" id="method-i-set_header">
                    
                    <a name="method-i-set_header"></a><b>set_header</b>(header, value)
                    
                </div>
                
                <div class="description">
                  <p>
Change one of the authentication headers.
</p>
<p>
Args:
</p>
<ul>
<li><p>
header: the name for the header being changed.
</p>
</li>
<li><p>
value: the new value for the header.
</p>
</li>
</ul>

                </div>
                
                
                
                
                <div class="sourcecode">
                    <p class="source-link">
                        Source: <a href="javascript:toggleSource('method-i-set_header_source')" id="l_method-i-set_header_source">show</a>
                        
                    </p>
                    <div id="method-i-set_header_source" class="dyn-source">
                        <pre>     <span class="ruby-comment cmt"># File lib/adwords4r/credentials.rb, line 303</span>
303:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_header</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">value</span>)
304:       <span class="ruby-comment cmt"># Invalidate previous auth token if necessary</span>
305:       <span class="ruby-ivar">@auth_token</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">header</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'email'</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">header</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'password'</span>
306: 
307:       <span class="ruby-ivar">@credentials</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
308:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">header</span> <span class="ruby-keyword kw">then</span>
309:           <span class="ruby-ivar">@credentials</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
310:         <span class="ruby-keyword kw">end</span>
311:       <span class="ruby-keyword kw">end</span>
312:     <span class="ruby-keyword kw">end</span></pre>
                    </div>
                </div>
                
            </div>
            
</div>
    </div>
  </body>
</html>    